feat: propagate VarData.module_code into page module code#6456
feat: propagate VarData.module_code into page module code#6456FarhanAliRaza wants to merge 3 commits intoreflex-dev:mainfrom
Conversation
Adds module_code on VarData so Vars can contribute top-of-file JS helpers/constants. The default collector and the legacy _get_all_custom_code path both pick it up, ensuring snippets carried by Vars on memoized stateful components aren't dropped from the memo file.
Merging this PR will degrade performance by 23.15%
Performance Changes
Comparing Footnotes
|
Greptile SummaryThis PR adds a
Confidence Score: 4/5Core implementation is correct and well-tested; the only defect is in the new integration test's URL construction, which would cause two of the three new playwright tests to navigate to wrong addresses. The module_code field, its merge logic, and all three collection paths are implemented correctly. The integration test for /multi and /hook routes concatenates frontend_url directly with the path segment without a leading slash or .removesuffix('/'), so those tests would navigate to malformed URLs and fail to validate the behavior they were written to cover. tests/integration/tests_playwright/test_var_module_code.py — both routed test functions need the URL construction fixed before the integration tests can be relied on. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["VarData\nmodule_code field"] -->|merge / dedup| B["VarData.merge"]
B --> C["Var._get_all_var_data"]
C --> D["Component._iter_var_module_code"]
D --> E["Legacy path\n_get_all_custom_code"]
D --> F["Plugin path\n_collect_var_module_code"]
D --> G["Memo path\n_root_only_custom_code"]
E --> H["Page module_code dict"]
F --> H
G --> H
Reviews (1): Last reviewed commit: "feat: propagate VarData.module_code into..." | Re-trigger Greptile |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Adds module_code on VarData so Vars can contribute top-of-file JS helpers/constants. The default collector and the legacy _get_all_custom_code path both pick it up, ensuring snippets carried by Vars on memoized stateful components aren't dropped from the memo file.
All Submissions:
Type of change
Please delete options that are not relevant.
New Feature Submission:
Changes To Core Features:
closes #6219